
import Vue from "vue"
import VueRouter from "vue-router"

Vue.use(VueRouter)

import ErrorRoutes from "@/views/errorpage/route"
import SigninRoutes from "@/views/signin/route"
import MainRoutes  from "@/views/main/route"
import SearchRoutes from "@/views/search/route"
const routes = [
    {
      path:"/",
      redirect:"/guide"
    },
   {
     path:"/guide",
     name:'guide',
     component:()=>import("@/views/guide/guide.vue")
   },
   {
    path:"/city",
    name:'city',
    component:()=>import("@/views/city/city.vue")
  },
  {
    path:"/film/:filmId",
    name:'film',
    component:()=>import("@/views/film/film.vue")
  },
  {
    path:"/cinemas/:filmId?",
    name:'cinemas',
    component:()=>import("@/views/cinemas/cinemas.vue")
  },
   ...MainRoutes,
   ...SearchRoutes,
   ...ErrorRoutes,
   ...SigninRoutes,
   {
     path:"*",
     redirect:{
       name:'guide'
     }
   }
]


const router = new VueRouter({
  routes,
  mode:"hash"
})

import store from "../store"
import  {Dialog} from "vant"

router.beforeEach((to,from,next)=>{
  next()
  // if(to.name=='movie'||to.name=='cinema'){
  //     if(store.state.city){
  //       next()
  //     }else{
  //       next(false)
  //       Dialog.alert({
  //         title: '友情提示',
  //         message: '你没有选择城市,请去定位选择',
  //         theme: 'round-button',
  //       }).then(() => {
  //         // on close
  //         router.push({name:'city'})
  //       });
  //     }
  // }else{
  //   next()
  // }
})
export default router 
